package top.kaoshanji.s1ch08c;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/4/29 18:17
 */
@Controller
public class MainController {

    /**
     * 代码清单-s1ch08c-168页a：使用路径变量从客户端获取值
     * @param color
     * @param model
     * @return
     */
    @RequestMapping("/home/{color}")
    public String home(@PathVariable("color") String color, Model model) {
        model.addAttribute("username", "Katy");
        model.addAttribute("color", color);
        return "home.html";
    }

}
